<?php 
//判断版本是否需要更新
class Silk_Zgb_Block_Appupdate extends Mage_Core_Block_Template
{
    public function hasNew(){

        $newVersion = trim(Mage::getStoreConfig('general/zgb/app_version', Mage::app()->getStore()));
        if(!$newVersion) return false;


        $useragent = $_SERVER['HTTP_USER_AGENT'];
        $pattern = "/silkapp\/(\d+)\.(\d+)/";
        $match = array();
        preg_match($pattern, $useragent, $match);   //取出silkapp...

        if($match)
        {
            $bigVersion = $match[1];
            $smallVersion = $match[2];
            $versions = explode('.', $newVersion); 
            
            if(count($versions)!=2) return false;


            if($bigVersion < $versions[0])
            {
                return $newVersion;
            }

            if($bigVersion == $versions[0]  && $smallVersion < $versions[1])
            {
                return $newVersion;
            }
            return false;
        }
        else
        {
            return false;
        }
    }   
}